<template>
	<div>
		<city-header></city-header>
		<city-search :cities='cities'></city-search>
		<city-list :hotCities='hotCities' :cities='cities' :getAlphabetData='getAlphabetData'></city-list>
		<Alphabet :cities='cities' @change='getAlphabet'></Alphabet>
	</div>
</template>

<script>	
import CityHeader from './components/Header'
import CitySearch from './components/Search'
import CityList from './components/List'
import Alphabet from './components/Alphabet'
import axios from 'axios'
export default {
	name: 'City',
	components: {
		CityHeader,
		CitySearch,
		CityList,
		Alphabet
	},
	data () {
		return {
			hotCities: [],
			cities: {},
			getAlphabetData: ''
		}
	},
	methods: {
		getCityInfo () {
			axios.get('/api/city.json').then(this.getCityInfoSucc)
		},
		getCityInfoSucc (res) {
			res = res.data
			if (res.ret && res.data) {
				this.hotCities = res.data.hotCities
				this.cities = res.data.cities
			}
		},
		getAlphabet (meg) {	 
			this.getAlphabetData = meg
		}
	},
	mounted () {
		this.getCityInfo()
	}
}	
</script>

<style lang="stylus" scoped>
	
</style>